package sf.mybatis.mapper;

import db.domain.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.ByteArrayTypeHandler;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface UserMapper {
    User sel(int id);

    User selectBySorm(int id);

    User findByUsernameOrNickName(@Param("nickname") String nickname, @Param("loginName") String loginName,@Param("activationKey")String activationKey);

    @Select(value = "select * from wp_users where id > #{id} limit 1")
    @Results(id="sf.mapper.UserMapper.BaseResultMap",value={
            @Result(column="id", property="id", jdbcType= JdbcType.INTEGER, id=true),
            @Result(column="login_name", property="loginName", jdbcType=JdbcType.VARCHAR),
            @Result(column="password ", property="password", jdbcType=JdbcType.VARCHAR),
            @Result(column="nicename ", property="nicename", jdbcType=JdbcType.VARCHAR),
            @Result(column="icon ", property="icon", typeHandler = ByteArrayTypeHandler.class)
    })
    User findOne(@Param("id") Integer id);
}
